﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ASCalpuff.FileLayers
{
    /// <summary>
    /// 扩散和计算参数
    /// 垂直扩散常数，边界层扩散速率、随时间变化的扩散系数、描述城市上空烟羽扩散时的土地利用类型、烟羽路径系数等
    /// </summary>
    public class PG12:Group
    {

        /// <summary>
        /// 用于计算sigma-y 和sigma-z的时间依赖的(Heffter)分散方程的烟团的水平尺寸
        /// </summary>
        private double m_SYTDEP = 5.5E02;

        public double SYTDEP
        {
            get { return m_SYTDEP; }
            set { m_SYTDEP = value; }
        }
        /// <summary>
        /// 是否使用Heffter分散公式来计算sigma z （0＝否；１＝是）
        /// </summary>
        private int m_MHFTSZ = 0;

        public int MHFTSZ
        {
            get { return m_MHFTSZ; }
            set { m_MHFTSZ = value; }
        }
        /// <summary>
        /// 用来确定边界层以上烟团扩散速率的稳定度参数
        /// </summary>
        private int m_JSUP = 5;　　//

        public int JSUP
        {
            get { return m_JSUP; }
            set { m_JSUP = value; }
        }
        /// <summary>
        /// 稳定条件下的垂直扩散常数
        /// </summary>
        private double m_CONK1 = 0.01;//

        public double CONK1
        {
            get { return m_CONK1; }
            set { m_CONK1 = value; }
        }
        /// <summary>
        /// 中性条件或不稳定条件下的垂直扩散常数
        /// </summary>
        private double m_CONK2 = 0.1;//

        public double CONK2
        {
            get { return m_CONK2; }
            set { m_CONK2 = value; }
        }
        /// <summary>
        /// 决定从Schulman-Scire到Huber-Snyder 建筑物下洗机制的因子(SS用于Hs<Hb+TBD*HL)
        /// 有必要是集合吗？        /// 
        /// </summary>
        /// 


        private double m_TBD = 0.5;

        public double TBD
        {
            get { return m_TBD; }
            set { m_TBD = value; }
        }

        //private List<double> m_TBD = new List<double> ();

        //public List<double> TBD
        //{
        //    get { return m_TBD; }
        //    set { m_TBD = value; }
        //}
        /// <summary>
        /// 城市区域土地利用类型的区域范围。
        /// </summary>
        private int m_IURB1 = 10; //

        public int IURB1
        {
            get { return m_IURB1; }
            set { m_IURB1 = value; }
        }
        /// <summary>
        /// 城市区域土地利用类型的区域范围。
        /// </summary>
        private int m_IURB2 = 19;

        public int IURB2
        {
            get { return m_IURB2; }
            set { m_IURB2 = value; }
        }
        /// <summary>
        /// 模拟范围内的土地利用类型
        /// </summary>
        private int m_ILANDUIN = 20;　//

        public int ILANDUIN
        {
            get { return m_ILANDUIN; }
            set { m_ILANDUIN = value; }
        }
        /// <summary>
        /// 模拟范围的粗糙长度(m)
        /// </summary>
        private double m_Z0IN = 0.25;　//

        public double Z0IN
        {
            get { return m_Z0IN; }
            set { m_Z0IN = value; }
        }
        /// <summary>
        /// 模拟范围内的叶面积指数
        /// </summary>
        private double m_XLAIIN = 3.0;

        public double XLAIIN
        {
            get { return m_XLAIIN; }
            set { m_XLAIIN = value; }
        }
        /// <summary>
        /// 海拔高度(m)
        /// </summary>
        private double m_ELEVIN = 0;

        public double ELEVIN
        {
            get { return m_ELEVIN; }
            set { m_ELEVIN = value; }
        }
        /// <summary>
        /// /站点的北纬；北半球是正的，南半球是负的
        /// (用于在RIVAD/ARM3化学转换中计算太阳角
        /// </summary>
        private double m_XLATIN = -999.0;

        public double XLATIN
        {
            get { return m_XLATIN; }
            set { m_XLATIN = value; }
        }
        /// <summary>
        /// /站点的经度；西半球为负东半球为正
        /// (用于在RIVAD/ARM3化学转换中计算太阳角
        /// </summary>
        private double m_XLONIN = -999.0;

        public double XLONIN
        {
            get { return m_XLONIN; }
            set { m_XLONIN = value; }
        }
        /// <summary>
        /// 测风高度，单位米，used only if METFM = 2,3
        /// </summary>
        private double m_ANEMHT = 10;

        public double ANEMHT
        {
            get { return m_ANEMHT; }
            set { m_ANEMHT = value; }
        }
        /// <summary>
        /// //PROFILE.DAT文件中的侧向湍流数据的形式（只有在METFM=４或MTURBVW=1或3时使用）
        /// 0 = read sigma-theta
        /// 1 = read sigma-v
        /// </summary>
        private int m_ISIGMAV = 1;

        public int ISIGMAV
        {
            get { return m_ISIGMAV; }
            set { m_ISIGMAV = value; }
        }
        /// <summary>
        /// 混合层高度的选择（只有在METFM=4时使用）
        /// ,=0，读取预测混合层高度
        /// =1，读取观测混合层高度
        /// </summary>
        private int m_IMIXCTDM = 0;

        public int IMIXCTDM
        {
            get { return m_IMIXCTDM; }
            set { m_IMIXCTDM = value; }
        }
        /// <summary>
        /// 排放烟团的最大长度，单位网格单位
        /// </summary>
        private double m_XMXLEN = 1.0;

        public double XMXLEN
        {
            get { return m_XMXLEN; }
            set { m_XMXLEN = value; }
        }
        /// <summary>
        /// 烟团或者烟片在一个时间步长内移动的网格点数
        /// </summary>
        private double m_XSAMLEN = 1.0;

        public double XSAMLEN
        {
            get { return m_XSAMLEN; }
            set { m_XSAMLEN = value; }
        }
        /// <summary>
        /// 一个源在一个时间步长内释放烟团个数的最大值
        /// </summary>
        private int m_MXNEW = 99;

        public int MXNEW
        {
            get { return m_MXNEW; }
            set { m_MXNEW = value; }
        }
        /// <summary>
        /// 在一个时间步长内容许的最大采样步长的最大值
        /// </summary>
        private int m_MXSAM = 99;
        public int MXSAM
        {
            get { return m_MXSAM; }
            set { m_MXSAM = value; }
        }
        /// <summary>
        ///考虑过渡烟羽抬升的采样步长内，计算输送风的叠代次数,(used when METFM=1 or 4)
        /// </summary>
        private int m_NCOUNT = 2;

        public int NCOUNT
        {
            get { return m_NCOUNT; }
            set { m_NCOUNT = value; }
        }
        /// <summary>
        /// 新的烟团或烟片σy的最小值(m)
        /// </summary>
        private double m_SYMIN = 1.0;　//

        public double SYMIN
        {
            get { return m_SYMIN; }
            set { m_SYMIN = value; }
        }
        /// <summary>
        /// 新的烟团或烟片σv的最小值(m)
        /// </summary>
        private double m_SZMIN = 1.0;

        public double SZMIN
        {
            get { return m_SZMIN; }
            set { m_SZMIN = value; }
        }
        /// <summary>
        ///在计算虚时间或者距离时允许避免数值难题最大sigma-z 值
        /// </summary>
        private double m_SZCAP_M = 5.0E06;  //

        public double SZCAP_M
        {
            get { return m_SZCAP_M; }
            set { m_SZCAP_M = value; }
        }
        /// <summary>
        /// 陆面和海面每个稳定度最小湍流速度 sigma-v(m/s)
        /// 需要给出默认值
        /// </summary>
        private List<double> m_SVMIN = new List<double>();

        public List<double> SVMIN
        {
            get { return m_SVMIN; }
            set { m_SVMIN = value; }
        }
        /// <summary>
        /// 陆面和海面每个稳定度最小湍流速度 sigma-w(m/s)
        /// 需要给出默认值
        /// </summary>
        private List<double> m_SWMIN = new List<double>();

        public List<double> SWMIN
        {
            get { return m_SWMIN; }
            set { m_SWMIN = value; }
        }

        /// <summary>
        /// 在气象网格单元内的dw/dz偏离准则，常用于对水平收敛（１/s)的进行初始调整。部分调整在CDIV（１）时开始，全部调整在CDIV(2)完成。
        /// </summary>
        private double m_CDIV1;

        public double CDIV1
        {
            get { return m_CDIV1; }
            set { m_CDIV1 = value; }
        }
        /// <summary>
        /// 在气象网格单元内的dw/dz偏离准则，常用于对水平收敛（１/s)的进行初始调整。部分调整在CDIV（１）时开始，全部调整在CDIV(2)完成
        /// </summary>
        private double m_CDIV2;

        public double CDIV2
        {
            get { return m_CDIV2; }
            set { m_CDIV2 = value; }
        }
        /// <summary>
        /// 搜寻半径for nearest    land and water cells used in the subgrid   TIBL module 单位：网格数
        /// </summary>
        private int m_NLUTIBL = 4;　//

        public int NLUTIBL
        {
            get { return m_NLUTIBL; }
            set { m_NLUTIBL = value; }
        }
        /// <summary>
        ///非静态条件下允许的最小风速。比WSCALM要小风速被模型处理为静风。WSCALM也常用作从地面风速幂律指数外插出的最小风速。
        /// </summary>
        private double m_WSCALM = 0.5;

        public double WSCALM
        {
            get { return m_WSCALM; }
            set { m_WSCALM = value; }
        }
        /// <summary>
        /// 最大混合高度（m)
        /// </summary>
        private double m_XMAXZI = 3000; //

        public double XMAXZI
        {
            get { return m_XMAXZI; }
            set { m_XMAXZI = value; }
        }
        /// <summary>
        /// 最小混合高度(m)
        /// </summary>
        private double m_XMINZI = 50.0; //

        public double XMINZI
        {
            get { return m_XMINZI; }
            set { m_XMINZI = value; }
        }
        /// <summary>
        /// 烟片转化为烟团转换准则等于sigma-y/烟片的长度
        /// </summary>
        private double m_SL2PF = 10.0;　　//

        public double SL2PF
        {
            get { return m_SL2PF; }
            set { m_SL2PF = value; }
        }
        /// <summary>
        /// 前５个稳定度风速的上限(m/s)，第六个稳定度风速无上限。
        /// </summary>
        private List<double> m_WSCAT = new List<double>(); //　

        public List<double> WSCAT
        {
            get { return m_WSCAT; }
            set { m_WSCAT = value; }
        }
        /// <summary>
        /// 每个稳定度A-F的幂律廓线指数
        /// </summary>
        private List<double> m_PLX0 = new List<double>();

        public List<double> PLX0
        {
            get { return m_PLX0; }
            set { m_PLX0 = value; }
        }
        /// <summary>
        /// /稳定度E和F的位势温度梯度degK/m
        /// </summary>
        private double m_PTG01 = 0.02;

        public double PTG01
        {
            get { return m_PTG01; }
            set { m_PTG01 = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        private double m_PTG02 = 0.035;

        public double PTG02
        {
            get { return m_PTG02; }
            set { m_PTG02 = value; }
        }
        /// <summary>
        /// 每个稳定度默认烟羽路径系数
        /// （当选择局部烟羽高度地形调整的选项时使用，MCTADJ＝３）
        /// </summary>
        private List<double> m_PPC = new List<double>();

        public List<double> PPC
        {
            get { return m_PPC; }
            set { m_PPC = value; }
        }

        /// <summary>
        /// 烟团在每个时间分裂的烟团的数量；nsplit=2表示一个烟团分裂成２个
        /// </summary>
        private int m_NSPLIT = 3;

        public int NSPLIT
        {
            get { return m_NSPLIT; }
            set { m_NSPLIT = value; }
        }

        /// <summary>
        /// 一天内当分裂的烟团到达可以再次分裂条件的时间；一般每天设置一次，在入夜之前，日落左右设置。
        /// ２４时制：９是午夜（00：00），２３是下午１１点（23：00）
        /// 0＝不再次分裂；１＝达到可以再次分裂的条件
        /// </summary>
        private List<int> m_IRESPLIT = new List<int>();　//

        public List<int> IRESPLIT
        {
            get { return m_IRESPLIT; }
            set { m_IRESPLIT = value; }
        }
        /// <summary>
        /// 只有当最后小时的混合层高度（m)超过这个最小值时，才允许分裂
        /// </summary>
        private double m_ZISPLIT = 100.0;

        public double ZISPLIT
        {
            get { return m_ZISPLIT; }
            set { m_ZISPLIT = value; }
        }
        /// <summary>
        /// 当最后小时的混合层高度与烟团经历的最大混合层高度的比例比这个最大值还小时，才允许分裂（这就扒迟了分裂，直到出现夜间层）
        /// </summary>
        private double m_ROLDMAX = 0.25;

        public double ROLDMAX
        {
            get { return m_ROLDMAX; }
            set { m_ROLDMAX = value; }
        }

        //
        /// <summary>
        /// 面源积分的分步收敛值
        /// </summary>
        private double m_EPSAREA = 1.0E-06;　　//

        public double EPSAREA
        {
            get { return m_EPSAREA; }
            set { m_EPSAREA = value; }
        }
        /// <summary>
        /// 用于数值上升积分轨道步长(m)
        /// </summary>
        private double m_DSRISE = 1.0;

        public double DSRISE
        {
            get { return m_DSRISE; }
            set { m_DSRISE = value; }
        }
        /// <summary>
        /// 烟团在每个时间段分裂的数量
        /// </summary>
        private int m_NSPLITH = 5;　　　//

        public int NSPLITH
        {
            get { return m_NSPLITH; }
            set { m_NSPLITH = value; }
        }
        /// <summary>
        /// 烟团允许分裂前最小的sigma-y值(Grid Cells Units) 
        /// </summary>
        private double m_SYSPLITH = 1.0;

        public double SYSPLITH
        {
            get { return m_SYSPLITH; }
            set { m_SYSPLITH = value; }
        }
        /// <summary>
        /// 烟团允许分裂前由于风剪切最小烟团伸长率
        /// </summary>
        private double m_SHSPLITH = 2.0;

        public double SHSPLITH
        {
            get { return m_SHSPLITH; }
            set { m_SHSPLITH = value; }
        }
        /// <summary>
        /// 烟团中每个污染物的最小浓度
        /// 貌似这个应该是集合
        /// 如果只有一个值，那么将应用于每个污染物
        /// </summary>
        private double m_CNSPLITH = 1.0E-07;

        public double CNSPLITH
        {
            get { return m_CNSPLITH; }
            set { m_CNSPLITH = value; }
        }
        /// <summary>
        /// 模拟SLUG采样积分收敛性判别值
        /// </summary>
        private double m_EPSSLUG = 1.0E-04;

        public double EPSSLUG
        {
            get { return m_EPSSLUG; }
            set { m_EPSSLUG = value; }
        }

        /// <summary>
        /// 边界烟团混合的最小高度
        /// </summary>
        private double m_HTMINBC = 500;

        public double HTMINBC
        {
            get { return m_HTMINBC; }
            set { m_HTMINBC = value; }
        }
        /// <summary>
        /// sampling nearest BC puff搜寻半径
        /// </summary>
        private double m_RSAMPBC = 10;

        public double RSAMPBC
        {
            get { return m_RSAMPBC; }
            set { m_RSAMPBC = value; }
        }
        /// <summary>
        /// 浓度分布曲线的近地面消耗调整
        /// =0，不调整
        ///=1 调整
        /// </summary>
        private int m_MDEPBC = 1;

        public int MDEPBC
        {
            get { return m_MDEPBC; }
            set { m_MDEPBC = value; }
        }

        public override void ReadFromGroup(Dictionary<string, string> dic)
        {
            foreach (KeyValuePair<string, string> m_dic in dic)
            {

                if (m_dic.Key == "SYTDEP")
                {
                    this.SYTDEP = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "MHFTSZ")
                {
                    this.MHFTSZ = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "JSUP")
                {
                    this.JSUP = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "CONK1")
                {
                    this.CONK1 = Convert.ToDouble(m_dic.Value);
                }

                if (m_dic.Key == "CONK2")
                {
                    this.CONK2 = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "TBD")
                {
                    this.TBD = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "IURB1")
                {
                    this.IURB1 = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "IURB2")
                {
                    this.IURB2 = Convert.ToInt32(m_dic.Value);
                }

                if (m_dic.Key == "ILANDUIN")
                {
                    this.ILANDUIN = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "Z0IN")
                {
                    this.Z0IN = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "XLAIIN")
                {
                    this.XLAIIN = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "ELEVIN")
                {
                    this.ELEVIN = Convert.ToDouble(m_dic.Value);
                }

                if (m_dic.Key == "XLATIN")
                {
                    this.XLATIN = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "XLONIN")
                {
                    this.XLONIN = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "ANEMHT")
                {
                    this.ANEMHT = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "ISIGMAV")
                {
                    this.ISIGMAV = Convert.ToInt32(m_dic.Value);
                }

                if (m_dic.Key == "IMIXCTDM")
                {
                    this.IMIXCTDM = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "XMXLEN")
                {
                    this.XMXLEN = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "XSAMLEN")
                {
                    this.XSAMLEN = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "MXNEW")
                {
                    this.MXNEW = Convert.ToInt32(m_dic.Value);
                }

                if (m_dic.Key == "MXSAM")
                {
                    this.MXSAM = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "NCOUNT")
                {
                    this.NCOUNT = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "SYMIN")
                {
                    this.SYMIN = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "SZMIN")
                {
                    this.SZMIN = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "SZCAP_M")
                {
                    this.SZCAP_M = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "SVMIN")
                {
                    this.SVMIN = StrWriter.ReturnDouList(m_dic.Value);
                }
                if (m_dic.Key == "SWMIN")
                {
                    this.SWMIN = StrWriter.ReturnDouList(m_dic.Value);
                }
                if (m_dic.Key == "CDIV")
                {

                    if (StrWriter.ReturnBool(m_dic.Value, ",") == true)
                    {
                        string cdiv = "";
                        cdiv = StrWriter.GetString(m_dic.Value, 1);
                        cdiv = cdiv.Substring(1, cdiv.Length - 1);
                        this.CDIV1 = Convert.ToDouble(cdiv);
                        this.CDIV2 = Convert.ToDouble(StrWriter.GetString(m_dic.Value, 2));
                    }
                    else
                    {
                        this.CDIV1 = Convert.ToDouble(m_dic.Value);
                    }
                }
                if (m_dic.Key == "NLUTIBL")
                {
                    this.NLUTIBL = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "WSCALM")
                {
                    this.WSCALM = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "XMAXZI")
                {
                    this.XMAXZI = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "XMINZI")
                {
                    this.XMINZI = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "WSCAT")
                {
                    this.WSCAT = StrWriter.ReturnDouList(m_dic.Value);
                }
                if (m_dic.Key == "PLX0")
                {
                    this.PLX0 = StrWriter.ReturnDouList(m_dic.Value);
                }
                if (m_dic.Key == "PTG0")
                {

                    if (StrWriter.ReturnBool(m_dic.Value, ",") == true)
                    {
                        string cdiv = "";
                        cdiv = StrWriter.GetString(m_dic.Value, 1);
                        cdiv = cdiv.Substring(1, cdiv.Length - 1);
                        this.PTG01 = Convert.ToDouble(cdiv);
                        this.PTG02 = Convert.ToDouble(StrWriter.GetString(m_dic.Value, 2));
                    }
                    else
                    {
                        this.PTG01 = Convert.ToDouble(m_dic.Value);
                    }
                }
                if (m_dic.Key == "PPC")
                {
                    this.PPC = StrWriter.ReturnDouList(m_dic.Value);
                }
                if (m_dic.Key == "SL2PF")
                {
                    this.SL2PF = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "NSPLIT")
                {
                    this.NSPLIT = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "ZISPLIT")
                {
                    this.ZISPLIT = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "ROLDMAX")
                {
                    this.ROLDMAX = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "NSPLITH")
                {
                    this.NSPLITH = Convert.ToInt32(m_dic.Value);
                }
                if (m_dic.Key == "SYSPLITH")
                {
                    this.SYSPLITH = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "SHSPLITH")
                {
                    this.SHSPLITH = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "CNSPLITH")
                {
                    this.CNSPLITH = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "EPSSLUG")
                {
                    this.EPSSLUG = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "EPSAREA")
                {
                    this.EPSAREA = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "DSRISE")
                {
                    this.DSRISE = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "HTMINBC")
                {
                    this.HTMINBC = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "RSAMPBC")
                {
                    this.RSAMPBC = Convert.ToDouble(m_dic.Value);
                }
                if (m_dic.Key == "MDEPBC")
                {
                    this.MDEPBC = Convert.ToInt32(m_dic.Value);
                }

            }
        }
        public override string WriteToGroup()
        {
            string ResultStr = "", TempStr;

            TempStr = StrWriter.GetCLine();
            TempStr += "INPUT GROUP: 12 -- Misc. Dispersion and Computational Parameters" + "\r\n";
            ResultStr += TempStr;

            TempStr = StrWriter.GetCLine();
            ResultStr += TempStr;

            TempStr = "! SYTDEP = " + SYTDEP.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! MHFTSZ = " + MHFTSZ.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! JSUP = " + JSUP.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! CONK1 = " + CONK1.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! CONK2 = " + CONK2.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! TBD = ";
            //if (TBD.Count > 0)
            //{
            //    TempStr = "! TBD = " ;
            //    for (int i = 0; i < this.TBD.Count; i++)
            //    {
            //        if (i == this.TBD.Count - 1)
            //        {
            //            TempStr += this.TBD[i].ToString() ;
            //        }
            //        else
            //        {
            //            TempStr += this.TBD[i].ToString() + ",   ";
            //        }

            //    }
            //    TempStr += "   !" + "\r\n";
            //    ResultStr += TempStr;
            //}

            TempStr += this.TBD.ToString();
            TempStr += "   !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! IURB1 = " + IURB1.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! IURB2 = " + IURB2.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! ILANDUIN = " + ILANDUIN.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! Z0IN = " + Z0IN.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! XLAIIN = " + XLAIIN.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! ELEVIN = " + ELEVIN.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! XLATIN = " + XLATIN.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! XLONIN = " + XLONIN.ToString() + " !" + "\r\n";
            ResultStr += TempStr;


            TempStr = "! ANEMHT = " + ANEMHT.ToString() + " !" + "\r\n";
            ResultStr += TempStr;


            TempStr = "! ISIGMAV = " + ISIGMAV.ToString() + " !" + "\r\n";
            ResultStr += TempStr;


            TempStr = "! IMIXCTDM = " + IMIXCTDM.ToString() + " !" + "\r\n";
            ResultStr += TempStr;


            TempStr = "! XMXLEN = " + XMXLEN.ToString() + " !" + "\r\n";
            ResultStr += TempStr;


            TempStr = "! XSAMLEN = " + XSAMLEN.ToString() + " !" + "\r\n";
            ResultStr += TempStr;


            TempStr = "! MXNEW = " + MXNEW.ToString() + " !" + "\r\n";
            ResultStr += TempStr;


            TempStr = "! MXSAM = " + MXSAM.ToString() + " !" + "\r\n";
            ResultStr += TempStr;


            TempStr = "! NCOUNT = " + NCOUNT.ToString() + " !" + "\r\n";
            ResultStr += TempStr;


            TempStr = "! SYMIN = " + SYMIN.ToString() + " !" + "\r\n";
            ResultStr += TempStr;


            TempStr = "! SZMIN = " + SZMIN.ToString() + " !" + "\r\n";
            ResultStr += TempStr;


            TempStr = "! SZCAP_M = " + SZCAP_M.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            if (SVMIN.Count > 0)
            {
                TempStr = "! SVMIN = ";
                for (int i = 0; i < this.SVMIN.Count; i++)
                {
                    if (i == this.SVMIN.Count - 1)
                    {
                        TempStr += this.SVMIN[i].ToString();
                    }
                    else
                    {
                        TempStr += this.SVMIN[i].ToString() + ",   ";
                    }

                }
                TempStr += "   !" + "\r\n";
                ResultStr += TempStr;
            }


            if (SWMIN.Count > 0)
            {
                TempStr = "! SWMIN = ";
                for (int i = 0; i < this.SWMIN.Count; i++)
                {
                    if (i == this.SWMIN.Count - 1)
                    {
                        TempStr += this.SWMIN[i].ToString();
                    }
                    else
                    {
                        TempStr += this.SWMIN[i].ToString() + ",   ";
                    }

                }
                TempStr += "   !" + "\r\n";
                ResultStr += TempStr;
            }


            //if (this.CDIV2.ToString() != "")
            //{
            //    TempStr = "! CDIV = " + CDIV1.ToString() + " !" + "\r\n";
            //    ResultStr += TempStr;
            //}
            //else
            //{
            TempStr = "! CDIV =  " + CDIV1.ToString() + ",   " + CDIV2.ToString() + " !" + "\r\n";
            //}
            ResultStr += TempStr;

            TempStr = "! NLUTIBL = " + NLUTIBL.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! WSCALM = " + WSCALM.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! XMAXZI = " + XMAXZI.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! XMINZI = " + XMINZI.ToString() + " !" + "\r\n";
            ResultStr += TempStr;


            if (WSCAT.Count > 0)
            {
                TempStr = "! WSCAT = ";
                for (int i = 0; i < this.WSCAT.Count; i++)
                {
                    if (i == this.WSCAT.Count - 1)
                    {
                        TempStr += this.WSCAT[i].ToString();
                    }
                    else
                    {
                        TempStr += this.WSCAT[i].ToString() + ",   ";
                    }

                }
                TempStr += "   !" + "\r\n";
                ResultStr += TempStr;
            }


            if (PLX0.Count > 0)
            {
                TempStr = "! PLX0 = ";
                for (int i = 0; i < this.PLX0.Count; i++)
                {
                    if (i == this.PLX0.Count - 1)
                    {
                        TempStr += this.PLX0[i].ToString();
                    }
                    else
                    {
                        TempStr += this.PLX0[i].ToString() + ",   ";
                    }

                }
                TempStr += "   !" + "\r\n";
                ResultStr += TempStr;
            }


            //if (this.PTG02.ToString() != "")
            //{
            //    TempStr = "! PTG0 = " + PTG01.ToString() + " !" + "\r\n";
            //    ResultStr += TempStr;
            //}
            //else
            //{
            TempStr = "! PTG0 =  " + PTG01.ToString() + ",   " + PTG02.ToString() + " !" + "\r\n";
            //}
            ResultStr += TempStr;


            if (PPC.Count > 0)
            {
                TempStr = "! PPC = ";
                for (int i = 0; i < this.PPC.Count; i++)
                {
                    if (i == this.PPC.Count - 1)
                    {
                        TempStr += this.PPC[i].ToString();
                    }
                    else
                    {
                        TempStr += this.PPC[i].ToString() + ",   ";
                    }

                }
                TempStr += "   !" + "\r\n";
                ResultStr += TempStr;
            }


            TempStr = "! SL2PF = " + SL2PF.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! NSPLIT = " + NSPLIT.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            if (IRESPLIT.Count > 0)
            {
                TempStr = "! IRESPLIT =";
                for (int i = 0; i < IRESPLIT.Count; i++)
                {
                    if (i == IRESPLIT.Count - 1)
                    {
                        TempStr += IRESPLIT[i].ToString();
                    }
                    else
                    {
                        TempStr += IRESPLIT[i].ToString() + ",  ";
                    }
                }

                TempStr += "   !" + "\r\n";
                ResultStr += TempStr;
            }




            TempStr = "! ZISPLIT = " + ZISPLIT.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! ROLDMAX = " + ROLDMAX.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! NSPLITH = " + NSPLITH.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! SYSPLITH = " + SYSPLITH.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! SHSPLITH = " + SHSPLITH.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! CNSPLITH = " + CNSPLITH.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! EPSSLUG = " + EPSSLUG.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! EPSAREA = " + EPSAREA.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            //
            TempStr = "! DSRISE = " + DSRISE.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! HTMINBC = " + HTMINBC.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! RSAMPBC = " + RSAMPBC.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            TempStr = "! MDEPBC = " + MDEPBC.ToString() + " !" + "\r\n";
            ResultStr += TempStr;

            ResultStr += "!END!" + "\r\n";

            return ResultStr;
        }


    }
}
